# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: x11-base/xorg-x11rdp/xorg-x11rdp-0.5.0-r4.ebuild,v 1.1 2014/01/30 15:35:00 itspec.ru Exp $

EAPI="3"

inherit eutils

MY_P="x11rdp_xorg71"

DESCRIPTION="xorg-x11rdp"
HOMEPAGE="http://www.xrdp.org/"
SRC_URI="http://server1.xrdp.org/xrdp/${MY_P}.tar.gz http://www.x.org/releases/X11R7.0/src/proto/printproto-X11R7.0-1.0.3.tar.bz2 http://ftp.x.org/pub/X11R7.2/src/proto/printproto-X11R7.0-1.0.3.tar.bz2"

LICENSE="as-is"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE=""

DEPEND=""
RDEPEND="media-fonts/font-cursor-misc"

S=${WORKDIR}/${MY_P}

src_unpack() {
    unpack ${A}
    mv "${WORKDIR}/printproto-X11R7.0-1.0.3" "${S}"
}

src_prepare() {
    epatch "${FILESDIR}"/xorg-x11rdp-0.5.0-svn-r299.patch || die # aply changes from svn r299
    epatch "${FILESDIR}"/${PF}-buildx.patch || die
}

src_install() {
    mkdir -p "${D}"/usr/${PN} || die
    cd ${S}
    sh buildx.sh "${D}"/usr/${PN}
    if ! [ -f "${D}"/usr/${PN}/bin/X11rdp ]; then
        die 'build failed'
    fi
    dosym /usr/"${PN}"/bin/X11rdp /usr/bin/X11rdp
}

pkg_postinst() {
    elog
    elog "For testing X11rdp run"
    elog "\`X11rdp :10\`"
    elog
}
